<template>
	<view>
		<mh-navbar custom :back="true"  title="积分记录" fixed center zIndex="1010" />
		<view class="integral-wrap">
			<view v-for="(item, index) in integralList" :key="index">
				<view class="integral-list">
					<view class="integral-left">
						<view>{{item.description}}</view>
						<view>{{item.createTime}}</view>
					</view>
					<view class="integral-right">
						{{item.action}}{{item.integral}}积分
					</view>
				</view>
				<view style="height: 2px;background: #E5E5E5;"></view>
			</view>
		</view>
		<u-loadmore :status="status" :load-text="loadText"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 'loadmore',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				pageNum: 1,
				pageSize: 15,
				integralList:[],
			}
		},
		onLoad(){
			this.getIntegralList();
		},
		methods: {
			getIntegralList(){
				this.status = 'loading';
				this.$u.api.integras({pageNum:this.pageNum,pageSize:this.pageSize}).then(res => {
					if (res.code == 200){
						if(res.data.length > 0){
							this.integralList = this.integralList.concat(res.data);
							debugger
							this.status = 'loadmore';
						}else{
							this.status = 'nomore';
						}
					}
				});
			},
			onReachBottom() {
				debugger
				this.pageNum = ++ this.pageNum;
				this.getIntegralList();
			}
		}
	}
</script>

<style lang='scss'>
.integral-wrap{
	.integral-list{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		background: #ffff;
		padding: 0 10px;
		height: 60px;
		.integral-left{
			height: 100%;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
		}
		.integral-right{
			color: red;
		}
	}
}

</style>
